<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath()+"/";
%>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="<%=basePath %>css/list.css">
		<link href="<%=basePath %>css/H-ui.min.css" rel="stylesheet" type="text/css" />
		<script src="<%=basePath %>js/jquery.min.js"></script>
		<link rel="stylesheet" href="<%=basePath %>lib/icheck/icheck.css">
		<link rel="stylesheet" href="<%=basePath %>css/xcConfirm.css" type="text/css">
        <script src="<%=basePath %>lib/My97DatePicker/WdatePicker.js"></script>
        <script src="<%=basePath %>lib/icheck/jquery.icheck.min.js"></script>
		<script src="<%=basePath %>js/H-ui.js"></script>
		<script src="${pageContext.request.contextPath}/lib/bootstrap-modal/2.2.4/bootstrap-modalmanager.js"></script>
        <script src="${pageContext.request.contextPath}/lib/bootstrap-modal/2.2.4/bootstrap-modal.js"></script>
        
         <script src="<%=basePath %>js/xcConfirm.js"></script>
         <script src="<%=basePath %>js/ajaxfileupload.js"></script>
        <style>
        	.input-text, .textarea{
        		width: auto;
        	}
        </style>
          <script type="text/javascript">

 		$(function() {
  		    	$(".hoverShowThisImg").click(function(){
  	    			var src = $(this).attr("id");
  	    			$("#showImg").attr("src",src);
  	    			$("#clickShowModal").click();
	        	});

 		});

        </script>
    </head>
    <body>
    	<div class="connect_wrap" >
    	<!-- 遍历列表数据 -->
    	<table class="table table-border table-bordered table-striped table-hover">
    		<tr style="font-weight: bold;">
    			<td>序号</td>
    			<td>客户端</td>
    			<td>版本</td>
    			<td>创建时间</td>
    			<td>版本号</td>
    			<td>是否强制更新</td>
    			<td>上传</td>
    		</tr>
    		<c:if test="${not empty results}">
    			<c:forEach items="${results}" var="result" varStatus="vs">
    			<tr>
    				<td>${vs.index + 1}</td>
	                <td>${result.type}</td>
	                <td><input type="text" value="${result.version}" id="inid${result.id}"/>
						<input onclick="submit('${result.id}')" type="button" value="提交"/></td>
	                <td>${result.createtime}</td>
					<td><input type="text" value="${result.versionCode}" id="versionCode${result.id}"/>
						<input onclick="submitCode('${result.id}')" type="button" value="提交"/></td>
					<td><input type="text" value="${result.enforcement}" id="enforcement${result.id}"/>
						<input onclick="submitEnforcement('${result.id}')" type="button" value="提交"/></td>
	                <td><c:if test="${result.type eq 'android'}"><input type="file" id="uploadFile" name="file"/></c:if></td>
	    		</tr>
    		</c:forEach>
    	</c:if> 
		</table>
    	</div>
    	    	
			
		<!-- 加载图片 -->
    	<a data-toggle="modal" href="#myModal" id="clickShowModal" class="btn btn-primary size-L" style="display:none">点击显示</a>
		<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-body">
				<img src="" alt="" id="showImg" style="width:100%;height:90%;" />		     	
		   </div>
		</div>
    </body>

	<form id="update_form" style="display: none;" method="post" action="<%=basePath %>app/version/update">
		<input name="id" id="aid"/>
		<input name="version" id="aversion"/>
		<input name="versionCode" id="aversionCode"/>
		<input name="enforcement" id="aenforcement"/>
	</form>

    <script>
    $(function(){
    	$.Huifold("#Huifold1 .item h4","#Huifold1 .item .info","fast",1,"click");
    	
    	$('.orderByRadio').iCheck({
    		checkboxClass: 'icheckbox-blue',
    		radioClass: 'iradio-blue',
    		increaseArea: '20%'
    	});
    	
    	$("#Huifold1 .item h4").click();
    	
    });

    function submit(id) {
		$("#aid").val(id);
		$("#aversion").val($("#inid" + id).val());
		$("#update_form").submit();
    }
    function submitCode(id) {
		$("#aid").val(id);
		$("#aversionCode").val($("#versionCode" + id).val());
		$("#update_form").submit();
    }
    function submitEnforcement(id) {
		$("#aid").val(id);
		$("#aenforcement").val($("#enforcement" + id).val());
		$("#update_form").submit();
    }

    $("#uploadFile").on('change', function () {
        $.ajaxFileUpload({
            fileElementId: 'uploadFile',    //需要上传的文件域的ID，即<input type="file">的ID。
            url: '/app/version/upload', //后台方法的路径
            type: 'post',   //当要提交自定义参数时，这个参数要设置成post
            dataType: 'json',   //服务器返回的数据类型。可以为xml,script,json,html。如果不填写，jQuery会自动判断。
            secureuri: false,   //是否启用安全提交，默认为false。
            async: true,   //是否是异步
            success: function (data) {   //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                alert(data.msg);
                location.reload();
            }
        });
    });
    </script>

</html>